package com.bonc.ioc.controller;

import com.bonc.ioc.base.controller.BaseController;
import com.bonc.ioc.common.util.AppReply;
import com.bonc.ioc.service.DirectoryService;
import com.bonc.ioc.validation.AppAuthAnnotation;
import com.bonc.ioc.vo.DirectoryVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0
 * @description:
 * @author: wangqinglin
 * @date: 2021/3/19 10:16
 * @change : 2021/3/19 10:16 by q8541q@163.com  for init
 */

@RestController
@RequestMapping("/knowledgeDir")
@Slf4j
public class DirectoryController extends BaseController {

    @Autowired
    private DirectoryService directoryService;

    /**
     * saveAddictsInfo
     * 保存 /编辑 知识产权目录 信息
     *
     * @param item:
     * @return com.bonc.ioc.common.util.AppReply
     * @author wangqinglin
     * @date 2021/3/18 15:41
     * @change 2021/3/18 15:41 by q8541q@163.com for init
     * @since 1.0.0
     */
    @PostMapping("/save")
    @AppAuthAnnotation
    public AppReply saveAddictsInfo(@RequestBody DirectoryVo item) {
        return AppReply.success(directoryService.save(item));
    }

    /**
     * deleteMadInfo
     * 删除 知识产权 信息
     *
     * @param key:
     * @return com.bonc.ioc.common.util.AppReply
     * @author wangqinglin
     * @date 2021/3/18 15:41
     * @change 2021/3/18 15:41 by q8541q@163.com for init
     * @since 1.0.0
     */
    @GetMapping("/delete")
    @AppAuthAnnotation
    public AppReply deleteMadInfo(@RequestParam String key) {
        return AppReply.success(directoryService.deleteByPrimaryKey(key));
    }

    @GetMapping("/getDirs")
    public AppReply getDirs() {
        return AppReply.success(directoryService.getDirs());
    }

}
